home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / 68K Specific / SetUpA4.h < prev   
Encoding:
C/C++ Source or Header  |  1995-04-12  |  1.4 KB  |  65 lines  |  [TEXT/MMCC]

  1. /*
  2.  *    File:        A4Stuff.h
  3.  *                ©1993-1995 metrowerks Inc. All rights reserved
  4.  *
  5.  *    Content:    CodeResource / DRVR / DA support functions
  6.  *
  7.  *    3 macros have been added to help with setting up the global
  8.  *    world for callbacks.  They are platform (68K and PPC) safe.
  9.  *    Call PrepareCallback() only after A4 is correct.  It must be 
  10.  *    called in the same segment as the callback.  Call EnterCallback() 
  11.  *    when you enter a callback that accesses globals or strings.  
  12.  *    Call ExitCallback() when you are ready to leave the callback.  
  13.  *    Please see A4Stuff.h for similiar functions to be used when
  14.  *    you enter or exit the main entry point of a code resource.
  15.  */
  16.  
  17. #ifndef __SETUPA4__
  18. #define __SETUPA4__
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24. #ifndef powerc
  25.  
  26.     #define PrepareCallback() RememberA4() 
  27.     #define EnterCallback() long oldA4 = SetUpA4()
  28.     #define ExitCallback() RestoreA4(oldA4)
  29.  
  30.     static void RememberA4(void);
  31.     
  32.     static asm long SetUpA4(void)
  33.     {
  34.         move.l    a4,d0
  35.         lea        storage,a4
  36.         move.l    (a4),a4
  37.         rts
  38.     
  39.     storage:    dc.l    0    /* this storage is only referenced thru data cache */
  40.     
  41.         entry    static RememberA4
  42.         lea        storage,a0
  43.         move.l    a4,(a0)
  44.         rts
  45.     }
  46.     
  47.     static long RestoreA4(long:__D0):__D0 = 0xC18C;
  48.  
  49. #else
  50.  
  51.     #define PrepareCallback() 
  52.     #define EnterCallback()
  53.     #define ExitCallback()
  54.     #define RememberA4()     0
  55.     #define SetUpA4()         0L
  56.     #define RestoreA4(x)    0L
  57.     
  58. #endif
  59.  
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63.  
  64. #endif
  65.